<?php session_start();?>
<!DOCTYPE html>
<html>
<head> 
<title> login </title>
<meta charset="UTF-8">
</head>
   <body>
<?php

	if ($_SERVER["REQUEST_METHOD"] == "POST")
	{  	echo "hello";
		$condb = mysqli_connect("localhost","root","password","PROJECT");
		
                
		if(isset($_POST['kurser']))
		{   
                    $courseid= $_POST['kurser'];
                    $id = $_SESSION['id'];// this variable is used to relate to specific user
                    
                    echo "courseid".$courseid."<br/>";
		     // sets variables to insert into database
                    
		   
                    
                    echo $id;

		    if(mysqli_connect_errno()) 
     		    {
      		    echo "connection failed " . mysqli_connect_error();
     		    }
		
		    $insert_2 ="INSERT INTO PERSON_TAKES_COURSE (COURSE_ID,ID) VALUES ('$courseid','$id');";
		    if (!mysqli_query($condb,$insert_2))
 		    {
  		    die('Error: ' . mysqli_error($con));
  		    }
                    
                  
	       } 
        } 
        else 
            {
                echo "forbidden";
            }
         ?>

	
 </body>